package com.tlw.leave.dao;

import com.tlw.leave.entity.Information;
import com.tlw.leave.entity.Vo.Conditions;
import com.tlw.leave.entity.Vo.LeaveTime;
import org.springframework.data.domain.Page;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.persistence.QueryHint;
import java.util.List;

@Repository
public interface InformationDao extends JpaRepository<Information,Integer> {

    //筛选
    @Query("select i from Information i where i.name=?1")
    public List<Information> findInformationName(String name);

    //分页查询
    @Query(value = "select * from Information i limit :page offset :total",nativeQuery = true)
    List<Information> getPageList(@Param("page") int page, @Param("total") int total);

    @Query(value = "select * from Information i where i.startDate=?1 and i.startDate=?2",nativeQuery = true)
    public List<Information> getPageListNum(Conditions conditions);

    @Query(value = "select * from Information i where i.startDate between i.startDate",nativeQuery = true)
    public List<Information> getPageListTime(LeaveTime leaveTime);

//    List<Information> find(Conditions conditions);

    List<Information> findAll(Specification specification);
}

